

use "stata data/max load for welfare calculations", clear


//This how I deconstruct welfare losses from UTS vs CS for the table that breaks them down...
gen ratio_triangle_to_total_loss = total_CS_lossestriangle/(total_UTS_rectangle+total_CS_lossestriangle)
sum ratio_triangle_to_total_loss 
global ratio `r(mean)'

use "stata data\outcomes day_scenario all_days new price change 6 sensitivity scalar 1 in progress.dta" , clear
keep annual_value_co2
sum annual_value_co2
global annual_value_co2 `r(mean)'


use "stata data\outcomes day_scenario all_days new price change 6 sensitivity scalar 1.dta" , clear
keep total_construction_costs yearly_om_costs summer_long_1cent_gains summer_CS_losses discounted_value

gen ratio = $ratio

gen annual_value_co2 = $annual_value_co2

gen cs_loss = ratio * summer_CS_losses
gen uts_loss  = (1-ratio) * summer_CS_losses

drop summer_CS_losses ratio

order total_construction_costs yearly_om_costs cs_loss uts_loss summer_long annual discounted_value

xpose, clear var 

order _varname
rename v1 value
replace value = round(value /1000000,.01)
replace value = round(value) if inlist(_varname, "total_construction_costs","discounted_value")

gen label = ""
gen row = _n

replace label = "Peak capacity construction costs (one time)" if row == 1
replace label = "Avoided staffing and maintenance costs" if row == 2
replace label = "Net consumer surplus losses" if row == 3
replace label = "Net utility surplus losses" if row == 4
replace label = "Off peak \$.01/kWh discount" if row == 5
replace label = "Environmental benefits" if row == 6
replace label = "Total benefits" if row == 7

keep label value
order label value

save "latex/inputs_for_table_8", replace


*I built table 8 in a web based latex builder. The values in the DTA file above populate that table. 
